﻿@{
    Layout = null;
    MICZ.CodeBuilder.ViewModels.WorkContent WorkContent = ViewBag.WorkContent;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link href="@WorkContent.ThemePath/layui/css/layui.css" rel="stylesheet" />
    <script src="@WorkContent.ThemePath/layui/layui.js"></script>
    <script src="@WorkContent.ThemePath/js/jquery-3.4.1.min.js"></script>
    <script src="@WorkContent.ThemePath/bais.js"></script>
    <link href="@WorkContent.ThemePath/Login/Login.css" rel="stylesheet" />
    <script type="text/javascript">
        if (window != top)
            top.location.href = location.href;
    </script>
    <style>
        .user-add {
            text-align: center;
            color: #2196F3;
            font-weight: bold;
        }

            .user-add a {
                color: #F44336;
            }
    </style>
</head>
<body>
    <div class="login-top">
        <div class="head-main">
        </div>
    </div>
    <div class="login-body">
        <div class="login-main">
            <div class="left_text_wrap">
                <img src="~/Content/images/Logo.png" />
                <h1>版权所有 © 非遗大数据信息管理系统</h1>
            </div>
            <form action="/ManageAPI/Login/Ok" class="layui-form" method="post">
                <p class="form-title">登录</p>
                <div class="form-input">
                    <input type="text"  class="layui-input" placeholder = "请输入用户名" id="uid" name="uid"/>
                    @*@Html.TextBoxFor(m => m.UID, new { @class = "layui-input", placeholder = "请输入用户名", id = "account" })*@
                </div>
                <div class="form-input">
                    <input type="text"  class="layui-input" placeholder = "请输入密码" id="password" name="password"/>
                    @*@Html.PasswordFor(m => m.Password, new { @class = "layui-input", placeholder = "请输入用户名", id = "password" })*@
                </div>
                <div class="form-input">
                    <input type="text" name="vcode" id="vcode" required lay-verify="required" placeholder="验证码" autocomplete="off"
                           class="layui-input" onblur="if(this.value==''){this.value='验证码'}" onclick="if(this.value=='验证码'){this.value='';}" value="验证码">
                    <img id="checkloing" src="/ManageApi/VerifyCode/Img" width="70" height="40" onclick="reloadcode('/ManageApi/VerifyCode/Img')" title="看不清，换一张" style="" />
                </div>
                <div class="layui-input-block login-btn">
                    <button id="btnLogin" lay-submit lay-filter="login" class="layui-btn">登录</button>
                </div>
                <div class="user-add">
                    <p>还没有账号，点击<a href="#" id="zhuce">立即注册</a></p>
                    <p>注册即视为同意用户注册协议</p>
                </div>
                <hr />
            </form>
        </div>
    </div>
    <script>
        layui.use('layer', function () {
            var layer = layui.layer;
        });
        $("form").find("#zhuce").click(function () {
            layer.open({
                type: 2
                , area: ['500px', '300px']
                , title: '注册'
                , offset: 'auto'
                , resize: false
                ,shadeClose: true //点击遮罩关闭
                , content: '/Manage/Login/AddUser'
                , end: function () {//无论是确认还是取消，只要层被销毁了，end都会执行，不携带任何参数。layer.open关闭事件
                    location.reload();　　//layer.open关闭刷新
                }
            });
            return false;
        });

        //刷新验证码 js脚本代码
        function reloadcode(srcStr) {
            document.getElementById("checkloing").src = srcStr + "?rand=" + Math.random();
        }
        //点击登陆按钮
        $("form").find("button").click(function () {
            $.ajax({
                headers: header,
                //请求方式
                type: 'POST',
                //发送请求的地址
                url: '/ManageAPI/Login/Ok',
                //服务器返回的数据类型
                dataType: 'json',
                //发送到服务器的数据，对象必须为key/value的格式，jquery会自动转换为字符串格式
                data: $('form').serialize(),
                success: function (data) {
                    //请求成功函数内容
                        layer.msg(data.Msg);
                    if (data.Status == "1") {
                        //localStorage.setItem("token", data.Data.JWT);
                        //sessionStorage.setItem("token", data.Data.JWT);
                        localStorage.setItem("JWT", data.Data.JWT);
                        localStorage.setItem("token", data.Data.JWT.JwtStr);
                        location.href = data.Data.Src;
                    }
                    
                },
                error: function (data) {
                    //请求失败函数内容
                    layer.msg("数据请求错误!");//直接错误
                }
            });

            return false;
        });
    </script>
</body>
</html>
